programming4us
           
 
 
Windows Phone

Handling Input on Windows Phone 7 : Touch Input (part 1) - Single-Point Touch

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
8/11/2011 5:21:01 PM
Most modern mobile devices that have touch screens do not require a stylus, which was necessary for resistivetouch-based screens. Modern mobile devices are capacitive touch and respond very well to touch with a finger.

Windows Phone 7 supports up to four multi-touch contact points for XNA Framework development. Silverlight for Windows Phone supports two multi-touch contact points. As part of the platform, there is a touch driver and gesture engine under the covers that provides a consistent detection capability across hardware device OEMs and across applications.

As mentioned previously, Silverlight for Windows Phone 7 is based on Silverlight 3. The Windows Phone product team took the Silverlight 3 controls and APIs and optimized the controls for performance, for look and feel via control templates and styles and for input. The next section covers single-point touch as it relates to the controls optimized for Windows Phone 7.

1. Single-Point Touch

When a user clicks a Button control, TextBox control, ListBox control and the like on Windows Phone 7, it is single-point touch. For consistency, single-point touch events are translated to the Mouse events that you are familiar with when programming desktop Silverlight, Windows Forms, or other application frameworks. For example, touching a button appears as a Click event. Tapping to type text in a TextBox or touch a TextBlock control fires a MouseEnter, a MouseLeftButtonDown, a MouseLeftButtonUp, anda MouseLeave event.

SinglePointTouch project TextControlsMouseEventsPage.xaml page shows these events firing when you interact with the TextBox and TextBlockMouseEnter/MouseLeave pairs can fire. You can also see multiple MouseMove events fire as well as a result of small movements in your finger when interacting with the controls. It's something to consider when using these events with touch, as opposed to mouse clicks on the desktop, and why discrete events like listening for click or gestures is recommended except when discrete touch points are required. Figure 1 controls. You will notice when testing on a device that sometimes multiple shows the UI with the mouse events trace.

Figure 1. Text controls mouse events demo

Listing 1 shows the TextControslMouseEventPage.xaml code file with the XAML markup.

Example 1. WMAppManifest.xml Configuration File
<phone:PhoneApplicationPage
x:Class="SinglePointTouch.Pages.TextBoxMouseEventPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
mc:Ignorable="d" d:DesignHeight="768" d:DesignWidth="480"
shell:SystemTray.IsVisible="True">

<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>


</Grid.RowDefinitions>

<!--TitlePanel contains the name of the application and page title-->
<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
<TextBlock x:Name="ApplicationTitle" Text="Chapter 3 - SINGLE POINT TOUCH"
Style="{StaticResource PhoneTextNormalStyle}"/>
<TextBlock x:Name="PageTitle" Text="textbox mouse events" Margin="9,-7,0,0"
Style="{StaticResource PhoneTextTitle1Style}"/>
</StackPanel>
<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<StackPanel Orientation="Vertical">
<TextBox HorizontalAlignment="Left" x:Name="MouseEventsTextBox"
Text="TextBox Mouse Events Demo" Width="460" Height="72"
MouseEnter="MouseEventsTextBox_MouseEnter"
MouseLeave="MouseEventsTextBox_MouseLeave"
MouseLeftButtonDown="MouseEventsTextBox_MouseLeftButtonDown"
MouseLeftButtonUp="MouseEventsTextBox_MouseLeftButtonUp"
MouseMove="MouseEventsTextBox_MouseMove"
MouseWheel="MouseEventsTextBox_MouseWheel" />
<TextBlock Height="30" HorizontalAlignment="Left" Margin="12,0,0,0"
x:Name="MouseEventStatusText" Text="Mouse Events Log"
Width="438" />
<ListBox Height="217" x:Name="MouseEventLogListBox" />
<Rectangle Fill="#FFF4F4F5" Height="10" Stroke="Black" Margin="0,0,6,0"/>
<TextBlock TextWrapping="Wrap" Text="TextBlock Mouse Events Demo"
Margin="0" Name="TextBlockMouseEventsDemo"
MouseEnter="TextBlockMouseEventsDemo_MouseEnter"
MouseLeave="TextBlockMouseEventsDemo_MouseLeave"
MouseLeftButtonDown="TextBlockMouseEventsDemo_MouseLeftButtonDown"
MouseLeftButtonUp="TextBlockMouseEventsDemo_MouseLeftButtonUp"
MouseMove="TextBlockMouseEventsDemo_MouseMove"
MouseWheel="TextBlockMouseEventsDemo_MouseWheel" />
<TextBlock Height="30" HorizontalAlignment="Left" Margin="12,0,0,0"
x:Name="MouseEventStatusTextBlock" Text="Mouse Events Log"
Width="438" />
<ListBox Height="220" x:Name="MouseEventLogListBox2" />
</StackPanel>
</Grid>
</Grid>
</phone:PhoneApplicationPage>


In Listing 1, you can see the event handler assignments like this one assigning an event handler to the MouseEnter event for the MouseEventsTextBox object

MouseEnter="MouseEventsTextBox_MouseEnter"

The code-behind file has the related event handlers that simply write a text message to the MouseEventLogListBox like this one

private void MouseEventsTextBox_MouseEnter(object sender, MouseEventArgs e)
{
MouseEventLogListBox.Items.Add("MouseEnter event fired.");
}

Now that we have covered the mouse events, we will next look at how to use the mouse events for raw touch.
Other -----------------
- Handling Input on Windows Phone 7 : The Keyboard
- User Interface : Customizing the Soft Input Panel Keyboard to Accept Only Numbers
- User Interface : Detecting Changes in the Theme Template
- Developing for Windows Phone and Xbox Live : Multiplayer Games (part 6) - Searching for an Available Network Session
- Developing for Windows Phone and Xbox Live : Multiplayer Games (part 5) - Searching for an Available Network Session
- Developing for Windows Phone and Xbox Live : Multiplayer Games (part 4) - Building a Game Lobby
- Developing for Windows Phone and Xbox Live : Multiplayer Games (part 3) - Creating a Network Session
- Developing for Windows Phone and Xbox Live : Multiplayer Games (part 2) - Main Menu and State Management
- Developing for Windows Phone and Xbox Live : Multiplayer Games (part 1) - Getting Ready for Networking Development
- User Interface : Using the ApplicationBar Control
- User Interface : Creating an Animated Splash Screen
- Windows Phone 7 Game Development : The World of 3D Graphics - Vertex and Index Buffers
- Windows Phone 7 Game Development : The World of 3D Graphics - Hidden Surface Culling
- Windows Phone 7 Game Development : The World of 3D Graphics - The Depth Buffer
- Windows Phone 7 Game Development : The World of 3D Graphics - Rendering 3D Objects
- Windows Phone 7 Game Development : The World of 3D Graphics - Perspective Projection
- Developing for Windows Phone and Xbox Live : Let the 3D Rendering Start
- Developing for Windows Phone and Xbox Live : Reach and HiDef Graphics Profiles
- Developing for Windows Phone and Xbox Live : Graphics Pipeline
- Developing for Windows Phone and Xbox Live : Graphics Pipeline
 
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
- First look: Apple Watch

- 3 Tips for Maintaining Your Cell Phone Battery (part 1)

- 3 Tips for Maintaining Your Cell Phone Battery (part 2)
programming4us programming4us